//
//  UIButton+Extension.swift
//  SHWeibo2.0
//
//  Created by 黄礼潮 on 16/2/21.
//  Copyright © 2016年 黄礼潮. All rights reserved.
//

import UIKit


extension UIButton{


    convenience  init(cz_butitle title:String? ,imageName:String? = nil,backImageName:String? = nil,color:UIColor = UIColor.darkGrayColor(),fontSize: CGFloat = 17) {
        
        self.init()
        self.setTitle(title, forState: .Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        self.setTitleColor(color, forState: .Normal)
        
        if let imageName = imageName

        {
            self.setImage(UIImage(named:imageName), forState: .Normal)
            self.setImage(UIImage(named:imageName + "_highlighted"), forState: .Highlighted)
        }
 
        if let backImageName = backImageName {
        
            self.setBackgroundImage(UIImage(named:backImageName), forState: .Normal)
            self.setBackgroundImage(UIImage(named:backImageName + "_highlighted"), forState: .Highlighted)
        }
        
        //根据背景图片大小设置尺寸
        
        sizeToFit()
        
        
    }


}



